home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / window.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  3KB  |  140 lines

  1. #include "window.h"
  2. #include "global.h"
  3. #include "pcx.h"
  4.  
  5.  
  6. Window::Window(rect coordinates, char* fName, char* h, int s,
  7.                BORDERS b_type, BORDERS hdr_b_type,
  8.            int res, int pat, int hdr_pat)
  9.     : Border(coordinates, h, b_type, hdr_b_type, s, hdr_pat)
  10.     {
  11.     fileName = fName ? strdup(fName) : strdup("");
  12.     resize_status = fName ? res : FIXED;
  13.     once = 0;
  14.     pattern = pat;
  15.     }
  16. ////////////////////
  17. void Window::hilite()
  18.     {
  19.     mouseHideCursor();
  20.     Border::hilite();
  21.     mouseShowCursor();
  22.     }
  23. //////////////////////
  24. void Window::unhilite()
  25.     {
  26.     mouseHideCursor();
  27.     Border::unhilite();
  28.     mouseShowCursor();
  29.     }
  30. //////////////////////
  31. void Window::repose(rect new_pos)
  32.     {
  33.     rectangle = new_pos;
  34.     Header::len =
  35.         screenXL(new_pos.corner.X -
  36.          new_pos.origin.X - 1)
  37.          - area[border_type].origin.X -
  38.          area[border_type].corner.X - 2 * shadow;
  39.     }
  40. ////////////////////////
  41. void Window::exe(int act)
  42.     {
  43.     rect work = screenRect(rectangle);
  44.     switch(act)
  45.     {
  46.     case AC_MOVE:
  47.             global_i[0] = AC_REDRAW;
  48.             global_i[1] = AC_MOVE;
  49.         return;
  50.     case AC_RESIZE:
  51.             global_i[0] = AC_REDRAW;
  52.             global_i[1] = AC_RESIZE;
  53.             return;
  54.     case 0:
  55.         default:
  56.         e.what = KEYEVENT;
  57.         e.key = 0;
  58.             global_i[0] = action_type;
  59.             global_num = 1;
  60.             return;
  61.     }
  62.     }
  63. /////////////////////////
  64. void Window::show()
  65.     {
  66.     mouseHideCursor();
  67.     settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
  68.     clrscr();
  69.     once = 1;
  70.     mouseShowCursor();
  71.     }
  72. ///////////////////
  73. void Window::show_window()
  74.     {
  75.     mouseHideCursor();
  76.     if(*fileName != '\0')
  77.         pcx_scr_file(screenRect(rectangle), fileName, 0);
  78.     show();
  79.     mouseShowCursor();
  80.     }
  81. ///////////////////
  82. void Window::hide()
  83.     {
  84.     mouseHideCursor();
  85.     if(!(ret & RET_STACKED) && *fileName != '\0')
  86.         pcx_file_scr(fileName, screenLocLT(rectangle.origin));
  87.     once = 0;
  88.     mouseShowCursor();
  89.     }
  90. //////////////////
  91. rect Window::user_screen()
  92.     {
  93.     return rect(screenXL(rectangle.origin.X)
  94.                   + area[border_type].origin.X + shadow,
  95.  
  96.         screenYT(rectangle.origin.Y)
  97.            + !(header == NULL) * (pScreenSet->standart_height + 2 +
  98.            area[hdr_b_type].origin.Y + area[hdr_b_type].corner.Y)
  99.                   + area[border_type].origin.Y + shadow,
  100.  
  101.         screenXR(rectangle.corner.X)
  102.                   - area[border_type].corner.X - shadow,
  103.  
  104.         screenYB(rectangle.corner.Y)
  105.                   - area[border_type].corner.Y - shadow);
  106.     }
  107. /////////////////////////////
  108. void Window::clrscr()
  109.     {
  110.     rect temp = user_screen();
  111.     mouseHideCursor();
  112.     if(pattern == 0)
  113.         {
  114.     setfillstyle(SOLID_FILL, (int)pColorSet->colors.BAK_COLOR);
  115.         bar(temp);
  116.         }
  117.     else
  118.         bar(temp,
  119.             (int)pColorSet->colors.BAK_COLOR,
  120.             (int)pColorSet->colors.FILL_COLOR, (uchar*)::pattern[pattern]);
  121.     Border::show();
  122.     mouseShowCursor();
  123.     }
  124. ///////////////////////////
  125. /*
  126. void main()
  127.     {
  128.     if(!init_KNOW_HOW())
  129.         return;
  130.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  131.     bar(0, 0, getmaxx(), getmaxy());
  132.  
  133.     Window w(rect(10, 10, 50, 20), "window.pcy", " KNOW-HOW 4.x",
  134.            6, SHOW_BORDER, SHOW_BORDER, MOVE | RESIZE, 18, 19);
  135.     w.show_window();
  136.     w.hide();
  137.     close_KNOW_HOW();
  138.     closegraph();
  139.     }
  140. */